//
//  BaseViewController.swift
//  微博
//
//  Created by mac on 15/12/13.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

class BaseViewController: UITableViewController ,BaseLoginViewDelegate {
    //定义一个baseLogin属性
    var baseView:BaseLoginView = BaseLoginView()
    //判断是不是访客模式
    //通过判断是否有解档是否为空来判断是不是访客模式
    var base = UserAccontViewMedol().userBase
    //创建一个父类控制器来模拟访客控制器
    override func loadView() {
        if base {
            //调用super的view来创建tableviewcontroller
            super.loadView()
        }else{
            loadBaseView()
        }
    }
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        
    }
    
    func loadBaseView() {
//        baseView = BaseLoginView()
        view = baseView
        
        //创建两个navItem
        let leftButton = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: "loginClick")
        navigationItem.rightBarButtonItem = leftButton
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "registerClick")
        navigationController?.navigationBar.tintColor = UIColor.orangeColor()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        //设置代理
        baseView.delegate = self
        
       
    }
    
    func loginClick() {
        print(__FUNCTION__)
        //跳转到当前的页面
        let oauth = OAuthViewController()
        let nvc = UINavigationController(rootViewController: oauth)
        presentViewController(nvc, animated: true, completion: nil)
    }
    func registerClick() {
        print(__FUNCTION__)
    }
    

}
